package com.shen.utils;

/**
 * 分页工具类
 * @author shen
 *
 */
public class Page implements java.io.Serializable {
	private static final long serialVersionUID = 6761723687959488320L;

	/** 总页数 **/
	private int totalPage;

	/** 记录总数 **/
	private long resultSum;

	/** 当前页码 **/
	private int pageNo;

	/** 每页记录数  **/
	private int pageSize;

	/** 分页时所传的参数  **/
	private String paramater;

	/**
	 * 构造器
	 */
	public Page() {
	}

	/**
	 * 构造器
	 * 
	 * @param resultSum 总记录数
	 * 
	 * @param pageSize 每页显示条数
	 * 
	 */
	public Page(long resultSum, int pageSize) {
		if (resultSum < 0) {
			throw new IllegalArgumentException("记录总数必须大于等于0.");
		}
		if (pageSize <= 0) {
			throw new IllegalArgumentException("页大小必须大于0.");
		}
		if (resultSum > 0) {
			this.resultSum = resultSum;
		}
		if (pageSize > 0) {
			this.pageSize = pageSize;
		}
		if (resultSum > 0 && pageSize > 0) {
			this.totalPage = (int) ((resultSum + pageSize - 1) / pageSize);
		}
		this.pageNo = 1;
	}

	/**
	 * @return the totalPage
	 */
	public int getTotalPage() {
		return totalPage;
	}

	/**
	 * @param totalPage the totalPage to set
	 */
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	/**
	 * @return the resultSum
	 */
	public long getResultSum() {
		return resultSum;
	}

	/**
	 * @param resultSum the resultSum to set
	 */
	public void setResultSum(long resultSum) {
		this.resultSum = resultSum;
	}

	/**
	 * @return the pageNo
	 */
	public int getPageNo() {
		return pageNo;
	}

	/**
	 * @param pageNo the pageNo to set
	 */
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * @param pageSize the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * @return the paramater
	 */
	public String getParamater() {
		return paramater;
	}

	/**
	 * @param paramater the paramater to set
	 */
	public void setParamater(String paramater) {
		this.paramater = paramater;
	}
}
